1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module glib.Str;
26 
27 private import core.stdc.stdio;
28 private import core.stdc.string;
29 private import glib.ErrorG;
30 private import glib.GException;
31 private import glib.Str;
32 private import glib.c.functions;
33 public  import glib.c.types;
34 public  import gobject.c.types;
35 
36 
37 /** */
38 public struct Str
39 {
40 	/*
41 	 * Convert C-style 0 terminated string s to char[] string.
42 	 * copied from phobos
43 	 */
44 	public static string toString(const(char)* s, size_t len = 0) pure
45 	{
46 		if ( s is null )
47 			return cast(string)null;
48 
49 		if ( len == 0 )
50 			len = strlen(s);
51 
52 		return s[0 .. len].idup;
53 	}
54 
55 	/*
56 	 * Convert array of chars s[] to a C-style 0 terminated string.
57 	 * copied from phobos
58 	 */
59 	public static char* toStringz(string s) pure
60 	{
61 		if ( s is null ) return null;
62 		char[] copy;
63 
64 		if (s.length == 0)
65 		{
66 			copy = "\0".dup;
67 		}
68 		else
69 		{
70 			// Need to make a copy
71 			copy = new char[s.length + 1];
72 			copy[0..s.length] = s[];
73 			copy[s.length] = 0;
74 		}
75 
76 		return copy.ptr;
77 	}
78 
79 	/** */
80 	public static char** toStringzArray(string[] args) pure
81 	{
82 		if ( args is null )
83 		{
84 			return null;
85 		}
86 		char** argv = (new char*[args.length + 1]).ptr;
87 		int argc = 0;
88 		foreach (string p; args)
89 		{
90 			argv[argc++] = cast(char*)(p.dup~'\0');
91 		}
92 		argv[argc] = null;
93 
94 		return argv;
95 	}
96 
97 	/** */
98 	public static char*** toStringzArray(string[][] args) pure
99 	{
100 		if ( args is null )
101 		{
102 			return null;
103 		}
104 		char**[] argv = new char**[args.length + 1];
105 		int argc = 0;
106 		foreach( string[] p; args )
107 		{
108 			argv[argc++] = toStringzArray(p);
109 		}
110 		argv[argc] = null;
111 
112 		return argv.ptr;
113 	}
114 
115 	/** */
116 	public static string[] toStringArray(const(char*)* args) pure
117 	{
118 		if ( args is null )
119 		{
120 			return null;
121 		}
122 		string[] argv;
123 
124 		while ( *args !is null )
125 		{
126 			argv ~= toString(*args);
127 			args++;
128 		}
129 
130 		return argv;
131 	}
132 
133 	/** */
134 	public static string[] toStringArray(const(char*)* args, size_t len) pure
135 	{
136 		string[] argv = new string[len];
137 
138 		for ( int i; i < len; i++ )
139 		{
140 			argv[i] = toString(args[i]);
141 		}
142 
143 		return argv;
144 	}
145 
146 	/** */
147 	public static string[][] toStringArray(char*** args) pure
148 	{
149 		string[][] argv;
150 
151 		if ( args is null )
152 		{
153 			return null;
154 		}
155 
156 		while ( *args !is null )
157 		{
158 			argv ~= toStringArray(*args);
159 			args++;
160 		}
161 
162 		return argv;
163 	}
164 
165 	/** */
166 	public static void freeString(char* str)
167 	{
168 		g_free(str);
169 	}
170 
171 	/** */
172 	public static void freeStringArray(char** str)
173 	{
174 		g_strfreev(str);
175 	}
176 
177 	/** */
178 	public static void freeStringArray(char*** str)
179 	{
180 		while ( *str !is null )
181 		{
182 			g_strfreev(*str);
183 			str++;
184 		}
185 
186 		g_free(str);
187 	}
188 
189 	/**
190 	 */
191 
192 	/**
193 	 * Determines the numeric value of a character as a decimal digit.
194 	 * Differs from g_unichar_digit_value() because it takes a char, so
195 	 * there's no worry about sign extension if characters are signed.
196 	 *
197 	 * Params:
198 	 *     c = an ASCII character
199 	 *
200 	 * Returns: If @c is a decimal digit (according to g_ascii_isdigit()),
201 	 *     its numeric value. Otherwise, -1.
202 	 */
203 	public static int asciiDigitValue(char c)
204 	{
205 		return g_ascii_digit_value(c);
206 	}
207 
208 	/**
209 	 * Converts a #gdouble to a string, using the '.' as
210 	 * decimal point.
211 	 *
212 	 * This function generates enough precision that converting
213 	 * the string back using g_ascii_strtod() gives the same machine-number
214 	 * (on machines with IEEE compatible 64bit doubles). It is
215 	 * guaranteed that the size of the resulting string will never
216 	 * be larger than %G_ASCII_DTOSTR_BUF_SIZE bytes, including the terminating
217 	 * nul character, which is always added.
218 	 *
219 	 * Params:
220 	 *     buffer = A buffer to place the resulting string in
221 	 *     bufLen = The length of the buffer.
222 	 *     d = The #gdouble to convert
223 	 *
224 	 * Returns: The pointer to the buffer with the converted string.
225 	 */
226 	public static string asciiDtostr(string buffer, int bufLen, double d)
227 	{
228 		auto retStr = g_ascii_dtostr(Str.toStringz(buffer), bufLen, d);
229 
230 		scope(exit) Str.freeString(retStr);
231 		return Str.toString(retStr);
232 	}
233 
234 	/**
235 	 * Converts a #gdouble to a string, using the '.' as
236 	 * decimal point. To format the number you pass in
237 	 * a printf()-style format string. Allowed conversion
238 	 * specifiers are 'e', 'E', 'f', 'F', 'g' and 'G'.
239 	 *
240 	 * The @format must just be a single format specifier
241 	 * starting with `%`, expecting a #gdouble argument.
242 	 *
243 	 * The returned buffer is guaranteed to be nul-terminated.
244 	 *
245 	 * If you just want to want to serialize the value into a
246 	 * string, use g_ascii_dtostr().
247 	 *
248 	 * Params:
249 	 *     buffer = A buffer to place the resulting string in
250 	 *     bufLen = The length of the buffer.
251 	 *     format = The printf()-style format to use for the
252 	 *         code to use for converting
253 	 *     d = The #gdouble to convert
254 	 *
255 	 * Returns: The pointer to the buffer with the converted string.
256 	 */
257 	public static string asciiFormatd(string buffer, int bufLen, string format, double d)
258 	{
259 		auto retStr = g_ascii_formatd(Str.toStringz(buffer), bufLen, Str.toStringz(format), d);
260 
261 		scope(exit) Str.freeString(retStr);
262 		return Str.toString(retStr);
263 	}
264 
265 	/**
266 	 * Compare two strings, ignoring the case of ASCII characters.
267 	 *
268 	 * Unlike the BSD strcasecmp() function, this only recognizes standard
269 	 * ASCII letters and ignores the locale, treating all non-ASCII
270 	 * bytes as if they are not letters.
271 	 *
272 	 * This function should be used only on strings that are known to be
273 	 * in encodings where the bytes corresponding to ASCII letters always
274 	 * represent themselves. This includes UTF-8 and the ISO-8859-*
275 	 * charsets, but not for instance double-byte encodings like the
276 	 * Windows Codepage 932, where the trailing bytes of double-byte
277 	 * characters include all ASCII letters. If you compare two CP932
278 	 * strings using this function, you will get false matches.
279 	 *
280 	 * Both @s1 and @s2 must be non-%NULL.
281 	 *
282 	 * Params:
283 	 *     s1 = string to compare with @s2
284 	 *     s2 = string to compare with @s1
285 	 *
286 	 * Returns: 0 if the strings match, a negative value if @s1 < @s2,
287 	 *     or a positive value if @s1 > @s2.
288 	 */
289 	public static int asciiStrcasecmp(string s1, string s2)
290 	{
291 		return g_ascii_strcasecmp(Str.toStringz(s1), Str.toStringz(s2));
292 	}
293 
294 	/**
295 	 * Converts all upper case ASCII letters to lower case ASCII letters.
296 	 *
297 	 * Params:
298 	 *     str = a string
299 	 *     len = length of @str in bytes, or -1 if @str is nul-terminated
300 	 *
301 	 * Returns: a newly-allocated string, with all the upper case
302 	 *     characters in @str converted to lower case, with semantics that
303 	 *     exactly match g_ascii_tolower(). (Note that this is unlike the
304 	 *     old g_strdown(), which modified the string in place.)
305 	 */
306 	public static string asciiStrdown(string str, ptrdiff_t len)
307 	{
308 		auto retStr = g_ascii_strdown(Str.toStringz(str), len);
309 
310 		scope(exit) Str.freeString(retStr);
311 		return Str.toString(retStr);
312 	}
313 
314 	/**
315 	 * Compare @s1 and @s2, ignoring the case of ASCII characters and any
316 	 * characters after the first @n in each string. If either string is
317 	 * less than @n bytes long, comparison will stop at the first nul byte
318 	 * encountered.
319 	 *
320 	 * Unlike the BSD strcasecmp() function, this only recognizes standard
321 	 * ASCII letters and ignores the locale, treating all non-ASCII
322 	 * characters as if they are not letters.
323 	 *
324 	 * The same warning as in g_ascii_strcasecmp() applies: Use this
325 	 * function only on strings known to be in encodings where bytes
326 	 * corresponding to ASCII letters always represent themselves.
327 	 *
328 	 * Params:
329 	 *     s1 = string to compare with @s2
330 	 *     s2 = string to compare with @s1
331 	 *     n = number of characters to compare
332 	 *
333 	 * Returns: 0 if the strings match, a negative value if @s1 < @s2,
334 	 *     or a positive value if @s1 > @s2.
335 	 */
336 	public static int asciiStrncasecmp(string s1, string s2, size_t n)
337 	{
338 		return g_ascii_strncasecmp(Str.toStringz(s1), Str.toStringz(s2), n);
339 	}
340 
341 	/**
342 	 * Converts a string to a #gdouble value.
343 	 *
344 	 * This function behaves like the standard strtod() function
345 	 * does in the C locale. It does this without actually changing
346 	 * the current locale, since that would not be thread-safe.
347 	 * A limitation of the implementation is that this function
348 	 * will still accept localized versions of infinities and NANs.
349 	 *
350 	 * This function is typically used when reading configuration
351 	 * files or other non-user input that should be locale independent.
352 	 * To handle input from the user you should normally use the
353 	 * locale-sensitive system strtod() function.
354 	 *
355 	 * To convert from a #gdouble to a string in a locale-insensitive
356 	 * way, use g_ascii_dtostr().
357 	 *
358 	 * If the correct value would cause overflow, plus or minus %HUGE_VAL
359 	 * is returned (according to the sign of the value), and %ERANGE is
360 	 * stored in %errno. If the correct value would cause underflow,
361 	 * zero is returned and %ERANGE is stored in %errno.
362 	 *
363 	 * This function resets %errno before calling strtod() so that
364 	 * you can reliably detect overflow and underflow.
365 	 *
366 	 * Params:
367 	 *     nptr = the string to convert to a numeric value.
368 	 *     endptr = if non-%NULL, it returns the
369 	 *         character after the last character used in the conversion.
370 	 *
371 	 * Returns: the #gdouble value.
372 	 */
373 	public static double asciiStrtod(string nptr, out string endptr)
374 	{
375 		char* outendptr = null;
376 
377 		auto __p = g_ascii_strtod(Str.toStringz(nptr), &outendptr);
378 
379 		endptr = Str.toString(outendptr);
380 
381 		return __p;
382 	}
383 
384 	/**
385 	 * Converts a string to a #gint64 value.
386 	 * This function behaves like the standard strtoll() function
387 	 * does in the C locale. It does this without actually
388 	 * changing the current locale, since that would not be
389 	 * thread-safe.
390 	 *
391 	 * This function is typically used when reading configuration
392 	 * files or other non-user input that should be locale independent.
393 	 * To handle input from the user you should normally use the
394 	 * locale-sensitive system strtoll() function.
395 	 *
396 	 * If the correct value would cause overflow, %G_MAXINT64 or %G_MININT64
397 	 * is returned, and `ERANGE` is stored in `errno`.
398 	 * If the base is outside the valid range, zero is returned, and
399 	 * `EINVAL` is stored in `errno`. If the
400 	 * string conversion fails, zero is returned, and @endptr returns @nptr
401 	 * (if @endptr is non-%NULL).
402 	 *
403 	 * Params:
404 	 *     nptr = the string to convert to a numeric value.
405 	 *     endptr = if non-%NULL, it returns the
406 	 *         character after the last character used in the conversion.
407 	 *     base = to be used for the conversion, 2..36 or 0
408 	 *
409 	 * Returns: the #gint64 value or zero on error.
410 	 *
411 	 * Since: 2.12
412 	 */
413 	public static long asciiStrtoll(string nptr, out string endptr, uint base)
414 	{
415 		char* outendptr = null;
416 
417 		auto __p = g_ascii_strtoll(Str.toStringz(nptr), &outendptr, base);
418 
419 		endptr = Str.toString(outendptr);
420 
421 		return __p;
422 	}
423 
424 	/**
425 	 * Converts a string to a #guint64 value.
426 	 * This function behaves like the standard strtoull() function
427 	 * does in the C locale. It does this without actually
428 	 * changing the current locale, since that would not be
429 	 * thread-safe.
430 	 *
431 	 * Note that input with a leading minus sign (`-`) is accepted, and will return
432 	 * the negation of the parsed number, unless that would overflow a #guint64.
433 	 * Critically, this means you cannot assume that a short fixed length input will
434 	 * never result in a low return value, as the input could have a leading `-`.
435 	 *
436 	 * This function is typically used when reading configuration
437 	 * files or other non-user input that should be locale independent.
438 	 * To handle input from the user you should normally use the
439 	 * locale-sensitive system strtoull() function.
440 	 *
441 	 * If the correct value would cause overflow, %G_MAXUINT64
442 	 * is returned, and `ERANGE` is stored in `errno`.
443 	 * If the base is outside the valid range, zero is returned, and
444 	 * `EINVAL` is stored in `errno`.
445 	 * If the string conversion fails, zero is returned, and @endptr returns
446 	 * @nptr (if @endptr is non-%NULL).
447 	 *
448 	 * Params:
449 	 *     nptr = the string to convert to a numeric value.
450 	 *     endptr = if non-%NULL, it returns the
451 	 *         character after the last character used in the conversion.
452 	 *     base = to be used for the conversion, 2..36 or 0
453 	 *
454 	 * Returns: the #guint64 value or zero on error.
455 	 *
456 	 * Since: 2.2
457 	 */
458 	public static ulong asciiStrtoull(string nptr, out string endptr, uint base)
459 	{
460 		char* outendptr = null;
461 
462 		auto __p = g_ascii_strtoull(Str.toStringz(nptr), &outendptr, base);
463 
464 		endptr = Str.toString(outendptr);
465 
466 		return __p;
467 	}
468 
469 	/**
470 	 * Converts all lower case ASCII letters to upper case ASCII letters.
471 	 *
472 	 * Params:
473 	 *     str = a string
474 	 *     len = length of @str in bytes, or -1 if @str is nul-terminated
475 	 *
476 	 * Returns: a newly allocated string, with all the lower case
477 	 *     characters in @str converted to upper case, with semantics that
478 	 *     exactly match g_ascii_toupper(). (Note that this is unlike the
479 	 *     old g_strup(), which modified the string in place.)
480 	 */
481 	public static string asciiStrup(string str, ptrdiff_t len)
482 	{
483 		auto retStr = g_ascii_strup(Str.toStringz(str), len);
484 
485 		scope(exit) Str.freeString(retStr);
486 		return Str.toString(retStr);
487 	}
488 
489 	/**
490 	 * Convert a character to ASCII lower case.
491 	 *
492 	 * Unlike the standard C library tolower() function, this only
493 	 * recognizes standard ASCII letters and ignores the locale, returning
494 	 * all non-ASCII characters unchanged, even if they are lower case
495 	 * letters in a particular character set. Also unlike the standard
496 	 * library function, this takes and returns a char, not an int, so
497 	 * don't call it on %EOF but no need to worry about casting to #guchar
498 	 * before passing a possibly non-ASCII character in.
499 	 *
500 	 * Params:
501 	 *     c = any character
502 	 *
503 	 * Returns: the result of converting @c to lower case. If @c is
504 	 *     not an ASCII upper case letter, @c is returned unchanged.
505 	 */
506 	public static char asciiTolower(char c)
507 	{
508 		return g_ascii_tolower(c);
509 	}
510 
511 	/**
512 	 * Convert a character to ASCII upper case.
513 	 *
514 	 * Unlike the standard C library toupper() function, this only
515 	 * recognizes standard ASCII letters and ignores the locale, returning
516 	 * all non-ASCII characters unchanged, even if they are upper case
517 	 * letters in a particular character set. Also unlike the standard
518 	 * library function, this takes and returns a char, not an int, so
519 	 * don't call it on %EOF but no need to worry about casting to #guchar
520 	 * before passing a possibly non-ASCII character in.
521 	 *
522 	 * Params:
523 	 *     c = any character
524 	 *
525 	 * Returns: the result of converting @c to upper case. If @c is not
526 	 *     an ASCII lower case letter, @c is returned unchanged.
527 	 */
528 	public static char asciiToupper(char c)
529 	{
530 		return g_ascii_toupper(c);
531 	}
532 
533 	/**
534 	 * Determines the numeric value of a character as a hexadecimal
535 	 * digit. Differs from g_unichar_xdigit_value() because it takes
536 	 * a char, so there's no worry about sign extension if characters
537 	 * are signed.
538 	 *
539 	 * Params:
540 	 *     c = an ASCII character.
541 	 *
542 	 * Returns: If @c is a hex digit (according to g_ascii_isxdigit()),
543 	 *     its numeric value. Otherwise, -1.
544 	 */
545 	public static int asciiXdigitValue(char c)
546 	{
547 		return g_ascii_xdigit_value(c);
548 	}
549 
550 	/**
551 	 * Calculates the maximum space needed to store the output
552 	 * of the sprintf() function.
553 	 *
554 	 * Params:
555 	 *     format = the format string. See the printf() documentation
556 	 *     args = the parameters to be inserted into the format string
557 	 *
558 	 * Returns: the maximum space needed to store the formatted string
559 	 */
560 	public static size_t printfStringUpperBound(string format, void* args)
561 	{
562 		return g_printf_string_upper_bound(Str.toStringz(format), args);
563 	}
564 
565 	/**
566 	 * Copies a nul-terminated string into the dest buffer, include the
567 	 * trailing nul, and return a pointer to the trailing nul byte.
568 	 * This is useful for concatenating multiple strings together
569 	 * without having to repeatedly scan for the end.
570 	 *
571 	 * Params:
572 	 *     dest = destination buffer.
573 	 *     src = source string.
574 	 *
575 	 * Returns: a pointer to trailing nul byte.
576 	 */
577 	public static string stpcpy(string dest, string src)
578 	{
579 		auto retStr = g_stpcpy(Str.toStringz(dest), Str.toStringz(src));
580 
581 		scope(exit) Str.freeString(retStr);
582 		return Str.toString(retStr);
583 	}
584 
585 	/**
586 	 * Looks whether the string @str begins with @prefix.
587 	 *
588 	 * Params:
589 	 *     str = a nul-terminated string
590 	 *     prefix = the nul-terminated prefix to look for
591 	 *
592 	 * Returns: %TRUE if @str begins with @prefix, %FALSE otherwise.
593 	 *
594 	 * Since: 2.2
595 	 */
596 	public static bool hasPrefix(string str, string prefix)
597 	{
598 		return g_str_has_prefix(Str.toStringz(str), Str.toStringz(prefix)) != 0;
599 	}
600 
601 	/**
602 	 * Looks whether the string @str ends with @suffix.
603 	 *
604 	 * Params:
605 	 *     str = a nul-terminated string
606 	 *     suffix = the nul-terminated suffix to look for
607 	 *
608 	 * Returns: %TRUE if @str end with @suffix, %FALSE otherwise.
609 	 *
610 	 * Since: 2.2
611 	 */
612 	public static bool hasSuffix(string str, string suffix)
613 	{
614 		return g_str_has_suffix(Str.toStringz(str), Str.toStringz(suffix)) != 0;
615 	}
616 
617 	/**
618 	 * Determines if a string is pure ASCII. A string is pure ASCII if it
619 	 * contains no bytes with the high bit set.
620 	 *
621 	 * Params:
622 	 *     str = a string
623 	 *
624 	 * Returns: %TRUE if @str is ASCII
625 	 *
626 	 * Since: 2.40
627 	 */
628 	public static bool isAscii(string str)
629 	{
630 		return g_str_is_ascii(Str.toStringz(str)) != 0;
631 	}
632 
633 	/**
634 	 * Checks if a search conducted for @search_term should match
635 	 * @potential_hit.
636 	 *
637 	 * This function calls g_str_tokenize_and_fold() on both
638 	 * @search_term and @potential_hit.  ASCII alternates are never taken
639 	 * for @search_term but will be taken for @potential_hit according to
640 	 * the value of @accept_alternates.
641 	 *
642 	 * A hit occurs when each folded token in @search_term is a prefix of a
643 	 * folded token from @potential_hit.
644 	 *
645 	 * Depending on how you're performing the search, it will typically be
646 	 * faster to call g_str_tokenize_and_fold() on each string in
647 	 * your corpus and build an index on the returned folded tokens, then
648 	 * call g_str_tokenize_and_fold() on the search term and
649 	 * perform lookups into that index.
650 	 *
651 	 * As some examples, searching for ‘fred’ would match the potential hit
652 	 * ‘Smith, Fred’ and also ‘Frédéric’.  Searching for ‘Fréd’ would match
653 	 * ‘Frédéric’ but not ‘Frederic’ (due to the one-directional nature of
654 	 * accent matching).  Searching ‘fo’ would match ‘Foo’ and ‘Bar Foo
655 	 * Baz’, but not ‘SFO’ (because no word has ‘fo’ as a prefix).
656 	 *
657 	 * Params:
658 	 *     searchTerm = the search term from the user
659 	 *     potentialHit = the text that may be a hit
660 	 *     acceptAlternates = %TRUE to accept ASCII alternates
661 	 *
662 	 * Returns: %TRUE if @potential_hit is a hit
663 	 *
664 	 * Since: 2.40
665 	 */
666 	public static bool matchString(string searchTerm, string potentialHit, bool acceptAlternates)
667 	{
668 		return g_str_match_string(Str.toStringz(searchTerm), Str.toStringz(potentialHit), acceptAlternates) != 0;
669 	}
670 
671 	/**
672 	 * Transliterate @str to plain ASCII.
673 	 *
674 	 * For best results, @str should be in composed normalised form.
675 	 *
676 	 * This function performs a reasonably good set of character
677 	 * replacements.  The particular set of replacements that is done may
678 	 * change by version or even by runtime environment.
679 	 *
680 	 * If the source language of @str is known, it can used to improve the
681 	 * accuracy of the translation by passing it as @from_locale.  It should
682 	 * be a valid POSIX locale string (of the form
683 	 * `language[_territory][.codeset][@modifier]`).
684 	 *
685 	 * If @from_locale is %NULL then the current locale is used.
686 	 *
687 	 * If you want to do translation for no specific locale, and you want it
688 	 * to be done independently of the currently locale, specify `"C"` for
689 	 * @from_locale.
690 	 *
691 	 * Params:
692 	 *     str = a string, in UTF-8
693 	 *     fromLocale = the source locale, if known
694 	 *
695 	 * Returns: a string in plain ASCII
696 	 *
697 	 * Since: 2.40
698 	 */
699 	public static string toAscii(string str, string fromLocale)
700 	{
701 		auto retStr = g_str_to_ascii(Str.toStringz(str), Str.toStringz(fromLocale));
702 
703 		scope(exit) Str.freeString(retStr);
704 		return Str.toString(retStr);
705 	}
706 
707 	/**
708 	 * Tokenises @string and performs folding on each token.
709 	 *
710 	 * A token is a non-empty sequence of alphanumeric characters in the
711 	 * source string, separated by non-alphanumeric characters.  An
712 	 * "alphanumeric" character for this purpose is one that matches
713 	 * g_unichar_isalnum() or g_unichar_ismark().
714 	 *
715 	 * Each token is then (Unicode) normalised and case-folded.  If
716 	 * @ascii_alternates is non-%NULL and some of the returned tokens
717 	 * contain non-ASCII characters, ASCII alternatives will be generated.
718 	 *
719 	 * The number of ASCII alternatives that are generated and the method
720 	 * for doing so is unspecified, but @translit_locale (if specified) may
721 	 * improve the transliteration if the language of the source string is
722 	 * known.
723 	 *
724 	 * Params:
725 	 *     string_ = a string
726 	 *     translitLocale = the language code (like 'de' or
727 	 *         'en_GB') from which @string originates
728 	 *     asciiAlternates = a
729 	 *         return location for ASCII alternates
730 	 *
731 	 * Returns: the folded tokens
732 	 *
733 	 * Since: 2.40
734 	 */
735 	public static string[] tokenizeAndFold(string string_, string translitLocale, out string[] asciiAlternates)
736 	{
737 		char** outasciiAlternates = null;
738 
739 		auto retStr = g_str_tokenize_and_fold(Str.toStringz(string_), Str.toStringz(translitLocale), &outasciiAlternates);
740 
741 		asciiAlternates = Str.toStringArray(outasciiAlternates);
742 
743 		scope(exit) Str.freeStringArray(retStr);
744 		return Str.toStringArray(retStr);
745 	}
746 
747 	/**
748 	 * For each character in @string, if the character is not in @valid_chars,
749 	 * replaces the character with @substitutor.
750 	 *
751 	 * Modifies @string in place, and return @string itself, not a copy. The
752 	 * return value is to allow nesting such as:
753 	 *
754 	 * |[<!-- language="C" -->
755 	 * g_ascii_strup (g_strcanon (str, "abc", '?'))
756 	 * ]|
757 	 *
758 	 * In order to modify a copy, you may use g_strdup():
759 	 *
760 	 * |[<!-- language="C" -->
761 	 * reformatted = g_strcanon (g_strdup (const_str), "abc", '?');
762 	 * ...
763 	 * g_free (reformatted);
764 	 * ]|
765 	 *
766 	 * Params:
767 	 *     string_ = a nul-terminated array of bytes
768 	 *     validChars = bytes permitted in @string
769 	 *     substitutor = replacement character for disallowed bytes
770 	 *
771 	 * Returns: the modified @string
772 	 */
773 	public static string strcanon(string string_, string validChars, char substitutor)
774 	{
775 		auto retStr = g_strcanon(Str.toStringz(string_), Str.toStringz(validChars), substitutor);
776 
777 		scope(exit) Str.freeString(retStr);
778 		return Str.toString(retStr);
779 	}
780 
781 	/**
782 	 * A case-insensitive string comparison, corresponding to the standard
783 	 * strcasecmp() function on platforms which support it.
784 	 *
785 	 * Deprecated: See g_strncasecmp() for a discussion of why this
786 	 * function is deprecated and how to replace it.
787 	 *
788 	 * Params:
789 	 *     s1 = a string
790 	 *     s2 = a string to compare with @s1
791 	 *
792 	 * Returns: 0 if the strings match, a negative value if @s1 < @s2,
793 	 *     or a positive value if @s1 > @s2.
794 	 */
795 	public static int strcasecmp(string s1, string s2)
796 	{
797 		return g_strcasecmp(Str.toStringz(s1), Str.toStringz(s2));
798 	}
799 
800 	/**
801 	 * Removes trailing whitespace from a string.
802 	 *
803 	 * This function doesn't allocate or reallocate any memory;
804 	 * it modifies @string in place. Therefore, it cannot be used
805 	 * on statically allocated strings.
806 	 *
807 	 * The pointer to @string is returned to allow the nesting of functions.
808 	 *
809 	 * Also see g_strchug() and g_strstrip().
810 	 *
811 	 * Params:
812 	 *     string_ = a string to remove the trailing whitespace from
813 	 *
814 	 * Returns: @string
815 	 */
816 	public static string strchomp(string string_)
817 	{
818 		auto retStr = g_strchomp(Str.toStringz(string_));
819 
820 		scope(exit) Str.freeString(retStr);
821 		return Str.toString(retStr);
822 	}
823 
824 	/**
825 	 * Removes leading whitespace from a string, by moving the rest
826 	 * of the characters forward.
827 	 *
828 	 * This function doesn't allocate or reallocate any memory;
829 	 * it modifies @string in place. Therefore, it cannot be used on
830 	 * statically allocated strings.
831 	 *
832 	 * The pointer to @string is returned to allow the nesting of functions.
833 	 *
834 	 * Also see g_strchomp() and g_strstrip().
835 	 *
836 	 * Params:
837 	 *     string_ = a string to remove the leading whitespace from
838 	 *
839 	 * Returns: @string
840 	 */
841 	public static string strchug(string string_)
842 	{
843 		auto retStr = g_strchug(Str.toStringz(string_));
844 
845 		scope(exit) Str.freeString(retStr);
846 		return Str.toString(retStr);
847 	}
848 
849 	/**
850 	 * Compares @str1 and @str2 like strcmp(). Handles %NULL
851 	 * gracefully by sorting it before non-%NULL strings.
852 	 * Comparing two %NULL pointers returns 0.
853 	 *
854 	 * Params:
855 	 *     str1 = a C string or %NULL
856 	 *     str2 = another C string or %NULL
857 	 *
858 	 * Returns: an integer less than, equal to, or greater than zero, if @str1 is <, == or > than @str2.
859 	 *
860 	 * Since: 2.16
861 	 */
862 	public static int strcmp0(string str1, string str2)
863 	{
864 		return g_strcmp0(Str.toStringz(str1), Str.toStringz(str2));
865 	}
866 
867 	/**
868 	 * Replaces all escaped characters with their one byte equivalent.
869 	 *
870 	 * This function does the reverse conversion of g_strescape().
871 	 *
872 	 * Params:
873 	 *     source = a string to compress
874 	 *
875 	 * Returns: a newly-allocated copy of @source with all escaped
876 	 *     character compressed
877 	 */
878 	public static string strcompress(string source)
879 	{
880 		auto retStr = g_strcompress(Str.toStringz(source));
881 
882 		scope(exit) Str.freeString(retStr);
883 		return Str.toString(retStr);
884 	}
885 
886 	/**
887 	 * Converts any delimiter characters in @string to @new_delimiter.
888 	 *
889 	 * Any characters in @string which are found in @delimiters are
890 	 * changed to the @new_delimiter character. Modifies @string in place,
891 	 * and returns @string itself, not a copy.
892 	 *
893 	 * The return value is to allow nesting such as:
894 	 *
895 	 * |[<!-- language="C" -->
896 	 * g_ascii_strup (g_strdelimit (str, "abc", '?'))
897 	 * ]|
898 	 *
899 	 * In order to modify a copy, you may use g_strdup():
900 	 *
901 	 * |[<!-- language="C" -->
902 	 * reformatted = g_strdelimit (g_strdup (const_str), "abc", '?');
903 	 * ...
904 	 * g_free (reformatted);
905 	 * ]|
906 	 *
907 	 * Params:
908 	 *     string_ = the string to convert
909 	 *     delimiters = a string containing the current delimiters,
910 	 *         or %NULL to use the standard delimiters defined in %G_STR_DELIMITERS
911 	 *     newDelimiter = the new delimiter character
912 	 *
913 	 * Returns: the modified @string
914 	 */
915 	public static string strdelimit(string string_, string delimiters, char newDelimiter)
916 	{
917 		auto retStr = g_strdelimit(Str.toStringz(string_), Str.toStringz(delimiters), newDelimiter);
918 
919 		scope(exit) Str.freeString(retStr);
920 		return Str.toString(retStr);
921 	}
922 
923 	/**
924 	 * Converts a string to lower case.
925 	 *
926 	 * Deprecated: This function is totally broken for the reasons discussed
927 	 * in the g_strncasecmp() docs - use g_ascii_strdown() or g_utf8_strdown()
928 	 * instead.
929 	 *
930 	 * Params:
931 	 *     string_ = the string to convert.
932 	 *
933 	 * Returns: the string
934 	 */
935 	public static string strdown(string string_)
936 	{
937 		auto retStr = g_strdown(Str.toStringz(string_));
938 
939 		scope(exit) Str.freeString(retStr);
940 		return Str.toString(retStr);
941 	}
942 
943 	/**
944 	 * Duplicates a string. If @str is %NULL it returns %NULL.
945 	 * The returned string should be freed with g_free()
946 	 * when no longer needed.
947 	 *
948 	 * Params:
949 	 *     str = the string to duplicate
950 	 *
951 	 * Returns: a newly-allocated copy of @str
952 	 */
953 	public static string strdup(string str)
954 	{
955 		auto retStr = g_strdup(Str.toStringz(str));
956 
957 		scope(exit) Str.freeString(retStr);
958 		return Str.toString(retStr);
959 	}
960 
961 	/**
962 	 * Similar to the standard C vsprintf() function but safer, since it
963 	 * calculates the maximum space required and allocates memory to hold
964 	 * the result. The returned string should be freed with g_free() when
965 	 * no longer needed.
966 	 *
967 	 * The returned string is guaranteed to be non-NULL, unless @format
968 	 * contains `%lc` or `%ls` conversions, which can fail if no multibyte
969 	 * representation is available for the given character.
970 	 *
971 	 * See also g_vasprintf(), which offers the same functionality, but
972 	 * additionally returns the length of the allocated string.
973 	 *
974 	 * Params:
975 	 *     format = a standard printf() format string, but notice
976 	 *         [string precision pitfalls][string-precision]
977 	 *     args = the list of parameters to insert into the format string
978 	 *
979 	 * Returns: a newly-allocated string holding the result
980 	 */
981 	public static string strdupVprintf(string format, void* args)
982 	{
983 		auto retStr = g_strdup_vprintf(Str.toStringz(format), args);
984 
985 		scope(exit) Str.freeString(retStr);
986 		return Str.toString(retStr);
987 	}
988 
989 	/**
990 	 * Copies %NULL-terminated array of strings. The copy is a deep copy;
991 	 * the new array should be freed by first freeing each string, then
992 	 * the array itself. g_strfreev() does this for you. If called
993 	 * on a %NULL value, g_strdupv() simply returns %NULL.
994 	 *
995 	 * Params:
996 	 *     strArray = a %NULL-terminated array of strings
997 	 *
998 	 * Returns: a new %NULL-terminated array of strings.
999 	 */
1000 	public static string[] strdupv(string[] strArray)
1001 	{
1002 		return Str.toStringArray(g_strdupv(Str.toStringzArray(strArray)));
1003 	}
1004 
1005 	/**
1006 	 * Returns a string corresponding to the given error code, e.g. "no
1007 	 * such process". Unlike strerror(), this always returns a string in
1008 	 * UTF-8 encoding, and the pointer is guaranteed to remain valid for
1009 	 * the lifetime of the process.
1010 	 *
1011 	 * Note that the string may be translated according to the current locale.
1012 	 *
1013 	 * The value of %errno will not be changed by this function. However, it may
1014 	 * be changed by intermediate function calls, so you should save its value
1015 	 * as soon as the call returns:
1016 	 * |[
1017 	 * int saved_errno;
1018 	 *
1019 	 * ret = read (blah);
1020 	 * saved_errno = errno;
1021 	 *
1022 	 * g_strerror (saved_errno);
1023 	 * ]|
1024 	 *
1025 	 * Params:
1026 	 *     errnum = the system error number. See the standard C %errno
1027 	 *         documentation
1028 	 *
1029 	 * Returns: a UTF-8 string describing the error code. If the error code
1030 	 *     is unknown, it returns a string like "unknown error (<code>)".
1031 	 */
1032 	public static string strerror(int errnum)
1033 	{
1034 		return Str.toString(g_strerror(errnum));
1035 	}
1036 
1037 	/**
1038 	 * Escapes the special characters '\b', '\f', '\n', '\r', '\t', '\v', '\'
1039 	 * and '"' in the string @source by inserting a '\' before
1040 	 * them. Additionally all characters in the range 0x01-0x1F (everything
1041 	 * below SPACE) and in the range 0x7F-0xFF (all non-ASCII chars) are
1042 	 * replaced with a '\' followed by their octal representation.
1043 	 * Characters supplied in @exceptions are not escaped.
1044 	 *
1045 	 * g_strcompress() does the reverse conversion.
1046 	 *
1047 	 * Params:
1048 	 *     source = a string to escape
1049 	 *     exceptions = a string of characters not to escape in @source
1050 	 *
1051 	 * Returns: a newly-allocated copy of @source with certain
1052 	 *     characters escaped. See above.
1053 	 */
1054 	public static string strescape(string source, string exceptions)
1055 	{
1056 		auto retStr = g_strescape(Str.toStringz(source), Str.toStringz(exceptions));
1057 
1058 		scope(exit) Str.freeString(retStr);
1059 		return Str.toString(retStr);
1060 	}
1061 
1062 	/**
1063 	 * Frees a %NULL-terminated array of strings, as well as each
1064 	 * string it contains.
1065 	 *
1066 	 * If @str_array is %NULL, this function simply returns.
1067 	 *
1068 	 * Params:
1069 	 *     strArray = a %NULL-terminated array of strings to free
1070 	 */
1071 	public static void strfreev(string[] strArray)
1072 	{
1073 		g_strfreev(Str.toStringzArray(strArray));
1074 	}
1075 
1076 	/**
1077 	 * Joins a number of strings together to form one long string, with the
1078 	 * optional @separator inserted between each of them. The returned string
1079 	 * should be freed with g_free().
1080 	 *
1081 	 * If @str_array has no items, the return value will be an
1082 	 * empty string. If @str_array contains a single item, @separator will not
1083 	 * appear in the resulting string.
1084 	 *
1085 	 * Params:
1086 	 *     separator = a string to insert between each of the
1087 	 *         strings, or %NULL
1088 	 *     strArray = a %NULL-terminated array of strings to join
1089 	 *
1090 	 * Returns: a newly-allocated string containing all of the strings joined
1091 	 *     together, with @separator between them
1092 	 */
1093 	public static string strjoinv(string separator, string[] strArray)
1094 	{
1095 		auto retStr = g_strjoinv(Str.toStringz(separator), Str.toStringzArray(strArray));
1096 
1097 		scope(exit) Str.freeString(retStr);
1098 		return Str.toString(retStr);
1099 	}
1100 
1101 	/**
1102 	 * Portability wrapper that calls strlcat() on systems which have it,
1103 	 * and emulates it otherwise. Appends nul-terminated @src string to @dest,
1104 	 * guaranteeing nul-termination for @dest. The total size of @dest won't
1105 	 * exceed @dest_size.
1106 	 *
1107 	 * At most @dest_size - 1 characters will be copied. Unlike strncat(),
1108 	 * @dest_size is the full size of dest, not the space left over. This
1109 	 * function does not allocate memory. It always nul-terminates (unless
1110 	 * @dest_size == 0 or there were no nul characters in the @dest_size
1111 	 * characters of dest to start with).
1112 	 *
1113 	 * Caveat: this is supposedly a more secure alternative to strcat() or
1114 	 * strncat(), but for real security g_strconcat() is harder to mess up.
1115 	 *
1116 	 * Params:
1117 	 *     dest = destination buffer, already containing one nul-terminated string
1118 	 *     src = source buffer
1119 	 *     destSize = length of @dest buffer in bytes (not length of existing string
1120 	 *         inside @dest)
1121 	 *
1122 	 * Returns: size of attempted result, which is MIN (dest_size, strlen
1123 	 *     (original dest)) + strlen (src), so if retval >= dest_size,
1124 	 *     truncation occurred.
1125 	 */
1126 	public static size_t strlcat(string dest, string src, size_t destSize)
1127 	{
1128 		return g_strlcat(Str.toStringz(dest), Str.toStringz(src), destSize);
1129 	}
1130 
1131 	/**
1132 	 * Portability wrapper that calls strlcpy() on systems which have it,
1133 	 * and emulates strlcpy() otherwise. Copies @src to @dest; @dest is
1134 	 * guaranteed to be nul-terminated; @src must be nul-terminated;
1135 	 * @dest_size is the buffer size, not the number of bytes to copy.
1136 	 *
1137 	 * At most @dest_size - 1 characters will be copied. Always nul-terminates
1138 	 * (unless @dest_size is 0). This function does not allocate memory. Unlike
1139 	 * strncpy(), this function doesn't pad @dest (so it's often faster). It
1140 	 * returns the size of the attempted result, strlen (src), so if
1141 	 * @retval >= @dest_size, truncation occurred.
1142 	 *
1143 	 * Caveat: strlcpy() is supposedly more secure than strcpy() or strncpy(),
1144 	 * but if you really want to avoid screwups, g_strdup() is an even better
1145 	 * idea.
1146 	 *
1147 	 * Params:
1148 	 *     dest = destination buffer
1149 	 *     src = source buffer
1150 	 *     destSize = length of @dest in bytes
1151 	 *
1152 	 * Returns: length of @src
1153 	 */
1154 	public static size_t strlcpy(string dest, string src, size_t destSize)
1155 	{
1156 		return g_strlcpy(Str.toStringz(dest), Str.toStringz(src), destSize);
1157 	}
1158 
1159 	/**
1160 	 * A case-insensitive string comparison, corresponding to the standard
1161 	 * strncasecmp() function on platforms which support it. It is similar
1162 	 * to g_strcasecmp() except it only compares the first @n characters of
1163 	 * the strings.
1164 	 *
1165 	 * Deprecated: The problem with g_strncasecmp() is that it does
1166 	 * the comparison by calling toupper()/tolower(). These functions
1167 	 * are locale-specific and operate on single bytes. However, it is
1168 	 * impossible to handle things correctly from an internationalization
1169 	 * standpoint by operating on bytes, since characters may be multibyte.
1170 	 * Thus g_strncasecmp() is broken if your string is guaranteed to be
1171 	 * ASCII, since it is locale-sensitive, and it's broken if your string
1172 	 * is localized, since it doesn't work on many encodings at all,
1173 	 * including UTF-8, EUC-JP, etc.
1174 	 *
1175 	 * There are therefore two replacement techniques: g_ascii_strncasecmp(),
1176 	 * which only works on ASCII and is not locale-sensitive, and
1177 	 * g_utf8_casefold() followed by strcmp() on the resulting strings,
1178 	 * which is good for case-insensitive sorting of UTF-8.
1179 	 *
1180 	 * Params:
1181 	 *     s1 = a string
1182 	 *     s2 = a string to compare with @s1
1183 	 *     n = the maximum number of characters to compare
1184 	 *
1185 	 * Returns: 0 if the strings match, a negative value if @s1 < @s2,
1186 	 *     or a positive value if @s1 > @s2.
1187 	 */
1188 	public static int strncasecmp(string s1, string s2, uint n)
1189 	{
1190 		return g_strncasecmp(Str.toStringz(s1), Str.toStringz(s2), n);
1191 	}
1192 
1193 	/**
1194 	 * Duplicates the first @n bytes of a string, returning a newly-allocated
1195 	 * buffer @n + 1 bytes long which will always be nul-terminated. If @str
1196 	 * is less than @n bytes long the buffer is padded with nuls. If @str is
1197 	 * %NULL it returns %NULL. The returned value should be freed when no longer
1198 	 * needed.
1199 	 *
1200 	 * To copy a number of characters from a UTF-8 encoded string,
1201 	 * use g_utf8_strncpy() instead.
1202 	 *
1203 	 * Params:
1204 	 *     str = the string to duplicate
1205 	 *     n = the maximum number of bytes to copy from @str
1206 	 *
1207 	 * Returns: a newly-allocated buffer containing the first @n bytes
1208 	 *     of @str, nul-terminated
1209 	 */
1210 	public static string strndup(string str, size_t n)
1211 	{
1212 		auto retStr = g_strndup(Str.toStringz(str), n);
1213 
1214 		scope(exit) Str.freeString(retStr);
1215 		return Str.toString(retStr);
1216 	}
1217 
1218 	/**
1219 	 * Creates a new string @length bytes long filled with @fill_char.
1220 	 * The returned string should be freed when no longer needed.
1221 	 *
1222 	 * Params:
1223 	 *     length = the length of the new string
1224 	 *     fillChar = the byte to fill the string with
1225 	 *
1226 	 * Returns: a newly-allocated string filled the @fill_char
1227 	 */
1228 	public static string strnfill(size_t length, char fillChar)
1229 	{
1230 		auto retStr = g_strnfill(length, fillChar);
1231 
1232 		scope(exit) Str.freeString(retStr);
1233 		return Str.toString(retStr);
1234 	}
1235 
1236 	/**
1237 	 * Reverses all of the bytes in a string. For example,
1238 	 * `g_strreverse ("abcdef")` will result in "fedcba".
1239 	 *
1240 	 * Note that g_strreverse() doesn't work on UTF-8 strings
1241 	 * containing multibyte characters. For that purpose, use
1242 	 * g_utf8_strreverse().
1243 	 *
1244 	 * Params:
1245 	 *     string_ = the string to reverse
1246 	 *
1247 	 * Returns: the same pointer passed in as @string
1248 	 */
1249 	public static string strreverse(string string_)
1250 	{
1251 		auto retStr = g_strreverse(Str.toStringz(string_));
1252 
1253 		scope(exit) Str.freeString(retStr);
1254 		return Str.toString(retStr);
1255 	}
1256 
1257 	/**
1258 	 * Searches the string @haystack for the last occurrence
1259 	 * of the string @needle.
1260 	 *
1261 	 * Params:
1262 	 *     haystack = a nul-terminated string
1263 	 *     needle = the nul-terminated string to search for
1264 	 *
1265 	 * Returns: a pointer to the found occurrence, or
1266 	 *     %NULL if not found.
1267 	 */
1268 	public static string strrstr(string haystack, string needle)
1269 	{
1270 		auto retStr = g_strrstr(Str.toStringz(haystack), Str.toStringz(needle));
1271 
1272 		scope(exit) Str.freeString(retStr);
1273 		return Str.toString(retStr);
1274 	}
1275 
1276 	/**
1277 	 * Searches the string @haystack for the last occurrence
1278 	 * of the string @needle, limiting the length of the search
1279 	 * to @haystack_len.
1280 	 *
1281 	 * Params:
1282 	 *     haystack = a nul-terminated string
1283 	 *     haystackLen = the maximum length of @haystack in bytes. A length of -1
1284 	 *         can be used to mean "search the entire string", like g_strrstr().
1285 	 *     needle = the nul-terminated string to search for
1286 	 *
1287 	 * Returns: a pointer to the found occurrence, or
1288 	 *     %NULL if not found.
1289 	 */
1290 	public static string strrstrLen(string haystack, ptrdiff_t haystackLen, string needle)
1291 	{
1292 		auto retStr = g_strrstr_len(Str.toStringz(haystack), haystackLen, Str.toStringz(needle));
1293 
1294 		scope(exit) Str.freeString(retStr);
1295 		return Str.toString(retStr);
1296 	}
1297 
1298 	/**
1299 	 * Returns a string describing the given signal, e.g. "Segmentation fault".
1300 	 * You should use this function in preference to strsignal(), because it
1301 	 * returns a string in UTF-8 encoding, and since not all platforms support
1302 	 * the strsignal() function.
1303 	 *
1304 	 * Params:
1305 	 *     signum = the signal number. See the `signal` documentation
1306 	 *
1307 	 * Returns: a UTF-8 string describing the signal. If the signal is unknown,
1308 	 *     it returns "unknown signal (<signum>)".
1309 	 */
1310 	public static string strsignal(int signum)
1311 	{
1312 		return Str.toString(g_strsignal(signum));
1313 	}
1314 
1315 	/**
1316 	 * Splits a string into a maximum of @max_tokens pieces, using the given
1317 	 * @delimiter. If @max_tokens is reached, the remainder of @string is
1318 	 * appended to the last token.
1319 	 *
1320 	 * As an example, the result of g_strsplit (":a:bc::d:", ":", -1) is a
1321 	 * %NULL-terminated vector containing the six strings "", "a", "bc", "", "d"
1322 	 * and "".
1323 	 *
1324 	 * As a special case, the result of splitting the empty string "" is an empty
1325 	 * vector, not a vector containing a single string. The reason for this
1326 	 * special case is that being able to represent an empty vector is typically
1327 	 * more useful than consistent handling of empty elements. If you do need
1328 	 * to represent empty elements, you'll need to check for the empty string
1329 	 * before calling g_strsplit().
1330 	 *
1331 	 * Params:
1332 	 *     string_ = a string to split
1333 	 *     delimiter = a string which specifies the places at which to split
1334 	 *         the string. The delimiter is not included in any of the resulting
1335 	 *         strings, unless @max_tokens is reached.
1336 	 *     maxTokens = the maximum number of pieces to split @string into.
1337 	 *         If this is less than 1, the string is split completely.
1338 	 *
1339 	 * Returns: a newly-allocated %NULL-terminated array of strings. Use
1340 	 *     g_strfreev() to free it.
1341 	 */
1342 	public static string[] strsplit(string string_, string delimiter, int maxTokens)
1343 	{
1344 		return Str.toStringArray(g_strsplit(Str.toStringz(string_), Str.toStringz(delimiter), maxTokens));
1345 	}
1346 
1347 	/**
1348 	 * Splits @string into a number of tokens not containing any of the characters
1349 	 * in @delimiter. A token is the (possibly empty) longest string that does not
1350 	 * contain any of the characters in @delimiters. If @max_tokens is reached, the
1351 	 * remainder is appended to the last token.
1352 	 *
1353 	 * For example the result of g_strsplit_set ("abc:def/ghi", ":/", -1) is a
1354 	 * %NULL-terminated vector containing the three strings "abc", "def",
1355 	 * and "ghi".
1356 	 *
1357 	 * The result of g_strsplit_set (":def/ghi:", ":/", -1) is a %NULL-terminated
1358 	 * vector containing the four strings "", "def", "ghi", and "".
1359 	 *
1360 	 * As a special case, the result of splitting the empty string "" is an empty
1361 	 * vector, not a vector containing a single string. The reason for this
1362 	 * special case is that being able to represent an empty vector is typically
1363 	 * more useful than consistent handling of empty elements. If you do need
1364 	 * to represent empty elements, you'll need to check for the empty string
1365 	 * before calling g_strsplit_set().
1366 	 *
1367 	 * Note that this function works on bytes not characters, so it can't be used
1368 	 * to delimit UTF-8 strings for anything but ASCII characters.
1369 	 *
1370 	 * Params:
1371 	 *     string_ = The string to be tokenized
1372 	 *     delimiters = A nul-terminated string containing bytes that are used
1373 	 *         to split the string (it can accept an empty string, which will result
1374 	 *         in no string splitting).
1375 	 *     maxTokens = The maximum number of tokens to split @string into.
1376 	 *         If this is less than 1, the string is split completely
1377 	 *
1378 	 * Returns: a newly-allocated %NULL-terminated array of strings. Use
1379 	 *     g_strfreev() to free it.
1380 	 *
1381 	 * Since: 2.4
1382 	 */
1383 	public static string[] strsplitSet(string string_, string delimiters, int maxTokens)
1384 	{
1385 		return Str.toStringArray(g_strsplit_set(Str.toStringz(string_), Str.toStringz(delimiters), maxTokens));
1386 	}
1387 
1388 	/**
1389 	 * Searches the string @haystack for the first occurrence
1390 	 * of the string @needle, limiting the length of the search
1391 	 * to @haystack_len.
1392 	 *
1393 	 * Params:
1394 	 *     haystack = a nul-terminated string
1395 	 *     haystackLen = the maximum length of @haystack in bytes. A length of -1
1396 	 *         can be used to mean "search the entire string", like `strstr()`.
1397 	 *     needle = the string to search for
1398 	 *
1399 	 * Returns: a pointer to the found occurrence, or
1400 	 *     %NULL if not found.
1401 	 */
1402 	public static string strstrLen(string haystack, ptrdiff_t haystackLen, string needle)
1403 	{
1404 		auto retStr = g_strstr_len(Str.toStringz(haystack), haystackLen, Str.toStringz(needle));
1405 
1406 		scope(exit) Str.freeString(retStr);
1407 		return Str.toString(retStr);
1408 	}
1409 
1410 	/**
1411 	 * Converts a string to a #gdouble value.
1412 	 * It calls the standard strtod() function to handle the conversion, but
1413 	 * if the string is not completely converted it attempts the conversion
1414 	 * again with g_ascii_strtod(), and returns the best match.
1415 	 *
1416 	 * This function should seldom be used. The normal situation when reading
1417 	 * numbers not for human consumption is to use g_ascii_strtod(). Only when
1418 	 * you know that you must expect both locale formatted and C formatted numbers
1419 	 * should you use this. Make sure that you don't pass strings such as comma
1420 	 * separated lists of values, since the commas may be interpreted as a decimal
1421 	 * point in some locales, causing unexpected results.
1422 	 *
1423 	 * Params:
1424 	 *     nptr = the string to convert to a numeric value.
1425 	 *     endptr = if non-%NULL, it returns the
1426 	 *         character after the last character used in the conversion.
1427 	 *
1428 	 * Returns: the #gdouble value.
1429 	 */
1430 	public static double strtod(string nptr, out string endptr)
1431 	{
1432 		char* outendptr = null;
1433 
1434 		auto __p = g_strtod(Str.toStringz(nptr), &outendptr);
1435 
1436 		endptr = Str.toString(outendptr);
1437 
1438 		return __p;
1439 	}
1440 
1441 	/**
1442 	 * Converts a string to upper case.
1443 	 *
1444 	 * Deprecated: This function is totally broken for the reasons
1445 	 * discussed in the g_strncasecmp() docs - use g_ascii_strup()
1446 	 * or g_utf8_strup() instead.
1447 	 *
1448 	 * Params:
1449 	 *     string_ = the string to convert
1450 	 *
1451 	 * Returns: the string
1452 	 */
1453 	public static string strup(string string_)
1454 	{
1455 		auto retStr = g_strup(Str.toStringz(string_));
1456 
1457 		scope(exit) Str.freeString(retStr);
1458 		return Str.toString(retStr);
1459 	}
1460 
1461 	/** */
1462 	public static GType strvGetType()
1463 	{
1464 		return g_strv_get_type();
1465 	}
1466 
1467 	/**
1468 	 * Returns the length of the given %NULL-terminated
1469 	 * string array @str_array. @str_array must not be %NULL.
1470 	 *
1471 	 * Params:
1472 	 *     strArray = a %NULL-terminated array of strings
1473 	 *
1474 	 * Returns: length of @str_array.
1475 	 *
1476 	 * Since: 2.6
1477 	 */
1478 	public static uint strvLength(string[] strArray)
1479 	{
1480 		return g_strv_length(Str.toStringzArray(strArray));
1481 	}
1482 
1483 	/**
1484 	 * Checks if @strv contains @str. @strv must not be %NULL.
1485 	 *
1486 	 * Params:
1487 	 *     strv = a %NULL-terminated array of strings
1488 	 *     str = a string
1489 	 *
1490 	 * Returns: %TRUE if @str is an element of @strv, according to g_str_equal().
1491 	 *
1492 	 * Since: 2.44
1493 	 */
1494 	public static bool strvContains(string strv, string str)
1495 	{
1496 		return g_strv_contains(Str.toStringz(strv), Str.toStringz(str)) != 0;
1497 	}
1498 
1499 	/**
1500 	 * An implementation of the GNU vasprintf() function which supports
1501 	 * positional parameters, as specified in the Single Unix Specification.
1502 	 * This function is similar to g_vsprintf(), except that it allocates a
1503 	 * string to hold the output, instead of putting the output in a buffer
1504 	 * you allocate in advance.
1505 	 *
1506 	 * The returned value in @string is guaranteed to be non-NULL, unless
1507 	 * @format contains `%lc` or `%ls` conversions, which can fail if no
1508 	 * multibyte representation is available for the given character.
1509 	 *
1510 	 * `glib/gprintf.h` must be explicitly included in order to use this function.
1511 	 *
1512 	 * Params:
1513 	 *     string_ = the return location for the newly-allocated string,
1514 	 *         which will be %NULL if (and only if) this function fails
1515 	 *     format = a standard printf() format string, but notice
1516 	 *         [string precision pitfalls][string-precision]
1517 	 *     args = the list of arguments to insert in the output.
1518 	 *
1519 	 * Returns: the number of bytes printed, or `-1` on failure
1520 	 *
1521 	 * Since: 2.4
1522 	 */
1523 	public static int vasprintf(string[] string_, string format, void* args)
1524 	{
1525 		return g_vasprintf(Str.toStringzArray(string_), Str.toStringz(format), args);
1526 	}
1527 
1528 	/**
1529 	 * An implementation of the standard vprintf() function which supports
1530 	 * positional parameters, as specified in the Single Unix Specification.
1531 	 *
1532 	 * `glib/gprintf.h` must be explicitly included in order to use this function.
1533 	 *
1534 	 * Params:
1535 	 *     format = a standard printf() format string, but notice
1536 	 *         [string precision pitfalls][string-precision]
1537 	 *     args = the list of arguments to insert in the output.
1538 	 *
1539 	 * Returns: the number of bytes printed.
1540 	 *
1541 	 * Since: 2.2
1542 	 */
1543 	public static int vprintf(string format, void* args)
1544 	{
1545 		return g_vprintf(Str.toStringz(format), args);
1546 	}
1547 
1548 	/**
1549 	 * A safer form of the standard vsprintf() function. The output is guaranteed
1550 	 * to not exceed @n characters (including the terminating nul character), so
1551 	 * it is easy to ensure that a buffer overflow cannot occur.
1552 	 *
1553 	 * See also g_strdup_vprintf().
1554 	 *
1555 	 * In versions of GLib prior to 1.2.3, this function may return -1 if the
1556 	 * output was truncated, and the truncated string may not be nul-terminated.
1557 	 * In versions prior to 1.3.12, this function returns the length of the output
1558 	 * string.
1559 	 *
1560 	 * The return value of g_vsnprintf() conforms to the vsnprintf() function
1561 	 * as standardized in ISO C99. Note that this is different from traditional
1562 	 * vsnprintf(), which returns the length of the output string.
1563 	 *
1564 	 * The format string may contain positional parameters, as specified in
1565 	 * the Single Unix Specification.
1566 	 *
1567 	 * Params:
1568 	 *     string_ = the buffer to hold the output.
1569 	 *     n = the maximum number of bytes to produce (including the
1570 	 *         terminating nul character).
1571 	 *     format = a standard printf() format string, but notice
1572 	 *         [string precision pitfalls][string-precision]
1573 	 *     args = the list of arguments to insert in the output.
1574 	 *
1575 	 * Returns: the number of bytes which would be produced if the buffer
1576 	 *     was large enough.
1577 	 */
1578 	public static int vsnprintf(string string_, gulong n, string format, void* args)
1579 	{
1580 		return g_vsnprintf(Str.toStringz(string_), n, Str.toStringz(format), args);
1581 	}
1582 
1583 	/**
1584 	 * An implementation of the standard vsprintf() function which supports
1585 	 * positional parameters, as specified in the Single Unix Specification.
1586 	 *
1587 	 * `glib/gprintf.h` must be explicitly included in order to use this function.
1588 	 *
1589 	 * Params:
1590 	 *     string_ = the buffer to hold the output.
1591 	 *     format = a standard printf() format string, but notice
1592 	 *         [string precision pitfalls][string-precision]
1593 	 *     args = the list of arguments to insert in the output.
1594 	 *
1595 	 * Returns: the number of bytes printed.
1596 	 *
1597 	 * Since: 2.2
1598 	 */
1599 	public static int vsprintf(string string_, string format, void* args)
1600 	{
1601 		return g_vsprintf(Str.toStringz(string_), Str.toStringz(format), args);
1602 	}
1603 
1604 	/**
1605 	 * An implementation of the standard fprintf() function which supports
1606 	 * positional parameters, as specified in the Single Unix Specification.
1607 	 *
1608 	 * `glib/gprintf.h` must be explicitly included in order to use this function.
1609 	 *
1610 	 * Params:
1611 	 *     file = the stream to write to.
1612 	 *     format = a standard printf() format string, but notice
1613 	 *         [string precision pitfalls][string-precision]
1614 	 *     args = the list of arguments to insert in the output.
1615 	 *
1616 	 * Returns: the number of bytes printed.
1617 	 *
1618 	 * Since: 2.2
1619 	 */
1620 	public static int vfprintf(FILE* file, string format, void* args)
1621 	{
1622 		return g_vfprintf(file, Str.toStringz(format), args);
1623 	}
1624 
1625 	/**
1626 	 * A convenience function for converting a string to a signed number.
1627 	 *
1628 	 * This function assumes that @str contains only a number of the given
1629 	 * @base that is within inclusive bounds limited by @min and @max. If
1630 	 * this is true, then the converted number is stored in @out_num. An
1631 	 * empty string is not a valid input. A string with leading or
1632 	 * trailing whitespace is also an invalid input.
1633 	 *
1634 	 * @base can be between 2 and 36 inclusive. Hexadecimal numbers must
1635 	 * not be prefixed with "0x" or "0X". Such a problem does not exist
1636 	 * for octal numbers, since they were usually prefixed with a zero
1637 	 * which does not change the value of the parsed number.
1638 	 *
1639 	 * Parsing failures result in an error with the %G_NUMBER_PARSER_ERROR
1640 	 * domain. If the input is invalid, the error code will be
1641 	 * %G_NUMBER_PARSER_ERROR_INVALID. If the parsed number is out of
1642 	 * bounds - %G_NUMBER_PARSER_ERROR_OUT_OF_BOUNDS.
1643 	 *
1644 	 * See g_ascii_strtoll() if you have more complex needs such as
1645 	 * parsing a string which starts with a number, but then has other
1646 	 * characters.
1647 	 *
1648 	 * Params:
1649 	 *     str = a string
1650 	 *     base = base of a parsed number
1651 	 *     min = a lower bound (inclusive)
1652 	 *     max = an upper bound (inclusive)
1653 	 *     outNum = a return location for a number
1654 	 *
1655 	 * Returns: %TRUE if @str was a number, otherwise %FALSE.
1656 	 *
1657 	 * Since: 2.54
1658 	 *
1659 	 * Throws: GException on failure.
1660 	 */
1661 	public static bool asciiStringToSigned(string str, uint base, long min, long max, out long outNum)
1662 	{
1663 		GError* err = null;
1664 
1665 		auto __p = g_ascii_string_to_signed(Str.toStringz(str), base, min, max, &outNum, &err) != 0;
1666 
1667 		if (err !is null)
1668 		{
1669 			throw new GException( new ErrorG(err) );
1670 		}
1671 
1672 		return __p;
1673 	}
1674 
1675 	/**
1676 	 * A convenience function for converting a string to an unsigned number.
1677 	 *
1678 	 * This function assumes that @str contains only a number of the given
1679 	 * @base that is within inclusive bounds limited by @min and @max. If
1680 	 * this is true, then the converted number is stored in @out_num. An
1681 	 * empty string is not a valid input. A string with leading or
1682 	 * trailing whitespace is also an invalid input. A string with a leading sign
1683 	 * (`-` or `+`) is not a valid input for the unsigned parser.
1684 	 *
1685 	 * @base can be between 2 and 36 inclusive. Hexadecimal numbers must
1686 	 * not be prefixed with "0x" or "0X". Such a problem does not exist
1687 	 * for octal numbers, since they were usually prefixed with a zero
1688 	 * which does not change the value of the parsed number.
1689 	 *
1690 	 * Parsing failures result in an error with the %G_NUMBER_PARSER_ERROR
1691 	 * domain. If the input is invalid, the error code will be
1692 	 * %G_NUMBER_PARSER_ERROR_INVALID. If the parsed number is out of
1693 	 * bounds - %G_NUMBER_PARSER_ERROR_OUT_OF_BOUNDS.
1694 	 *
1695 	 * See g_ascii_strtoull() if you have more complex needs such as
1696 	 * parsing a string which starts with a number, but then has other
1697 	 * characters.
1698 	 *
1699 	 * Params:
1700 	 *     str = a string
1701 	 *     base = base of a parsed number
1702 	 *     min = a lower bound (inclusive)
1703 	 *     max = an upper bound (inclusive)
1704 	 *     outNum = a return location for a number
1705 	 *
1706 	 * Returns: %TRUE if @str was a number, otherwise %FALSE.
1707 	 *
1708 	 * Since: 2.54
1709 	 *
1710 	 * Throws: GException on failure.
1711 	 */
1712 	public static bool asciiStringToUnsigned(string str, uint base, ulong min, ulong max, out ulong outNum)
1713 	{
1714 		GError* err = null;
1715 
1716 		auto __p = g_ascii_string_to_unsigned(Str.toStringz(str), base, min, max, &outNum, &err) != 0;
1717 
1718 		if (err !is null)
1719 		{
1720 			throw new GException( new ErrorG(err) );
1721 		}
1722 
1723 		return __p;
1724 	}
1725 
1726 	/**
1727 	 * Checks if @strv1 and @strv2 contain exactly the same elements in exactly the
1728 	 * same order. Elements are compared using g_str_equal(). To match independently
1729 	 * of order, sort the arrays first (using g_qsort_with_data() or similar).
1730 	 *
1731 	 * Two empty arrays are considered equal. Neither @strv1 not @strv2 may be
1732 	 * %NULL.
1733 	 *
1734 	 * Params:
1735 	 *     strv1 = a %NULL-terminated array of strings
1736 	 *     strv2 = another %NULL-terminated array of strings
1737 	 *
1738 	 * Returns: %TRUE if @strv1 and @strv2 are equal
1739 	 *
1740 	 * Since: 2.60
1741 	 */
1742 	public static bool strvEqual(string strv1, string strv2)
1743 	{
1744 		return g_strv_equal(Str.toStringz(strv1), Str.toStringz(strv2)) != 0;
1745 	}
1746 }